package org.awa.demo.opencv.task.kunming;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.awa.demo.opencv.gltf.SoundUtil;
import org.locationtech.jts.geom.Geometry;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@Data
public class GridBean {

    private Geometry geometry;
    private Double leqt;
    private List<ValueBean> leqtList = new ArrayList<>();

    public GridBean(Geometry geometry,double leqt) {
        this.geometry = geometry;
        appendLeqt(new ValueBean(leqt,Double.NaN));
    }

    public void appendLeqt(ValueBean valueBean){
        leqtList.add(valueBean);
    }

    public void superposition(){
        if(leqtList.size() == 0){
            this.leqt = Double.NaN;
            return;
        }
        if(leqtList.size() == 1){
            this.leqt = leqtList.get(0).getLeqt();
            return;
        }
        this.leqt = SoundUtil.soundSuperposition(this.leqtList.stream().map(ValueBean::getLeqt).collect(Collectors.toList()));
        if(leqt == Double.POSITIVE_INFINITY){
            log.info(">>>><<<<< "+ leqtList);
        }

    }


}
